﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data.EntityClient;

namespace Ecommerce.Model
{
    public abstract class BaseData
    {
        protected EntityConnection InicializarStringConexao()
        {
            SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();

            //===================================================
            //Configuração Desenvolvimento
            //===================================================
            //sqlBuilder.DataSource = "187.45.196.34";
            //sqlBuilder.InitialCatalog = "devsoftware1";
            //sqlBuilder.IntegratedSecurity = false;
            //sqlBuilder.MultipleActiveResultSets = true;
            //sqlBuilder.UserID = "devsoftware1";
            //sqlBuilder.Password = "bbz-001";

            //===================================================
            //Configuração Produção
            //===================================================
            sqlBuilder.DataSource = "187.45.196.35";
            sqlBuilder.InitialCatalog = "lojabambozzi1";
            sqlBuilder.IntegratedSecurity = false;
            sqlBuilder.MultipleActiveResultSets = true;
            sqlBuilder.UserID = "lojabambozzi1";
            sqlBuilder.Password = "cpd@bbz";

            EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
            builder.Provider = "System.Data.SqlClient";
            builder.Metadata = "res://*/ModelEcommerce.csdl|res://*/ModelEcommerce.ssdl|res://*/ModelEcommerce.msl";

            builder.ProviderConnectionString = sqlBuilder.ToString();

            EntityConnection entityConnection = new EntityConnection(builder.ToString());
            return entityConnection;
        }
    }

    public partial class EcommerceEntities
    {
        public EcommerceEntities(EntityConnection dbConnection, bool proxyCreate)
            : base(dbConnection, true)
        {
            this.Configuration.ProxyCreationEnabled = proxyCreate;
        }
    }
}